/*
 * Copyright (c) 2006-2024, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-04-05     RT-Thread    first version
 */

#include <rtthread.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#include "head_user.h"

static  rt_thread_t Uart1Tx_thread;
static  rt_thread_t FOC_thread;


#define Uart1Tx_thread_pri      16
#define FOC_thread_pri          16


int main(void)
{
    /* foc running */
    FOC_thread = rt_thread_create("FOC_Task", Foc_mainTask, RT_NULL, 1024, FOC_thread_pri, 10);
    if(FOC_thread != RT_NULL){
        rt_thread_startup(FOC_thread);
    }
    else{
        rt_kprintf("Foc_mainTask thread is failed to create!\r\n");
    }
#if 0
    /* uart upper computer communication */
    Uart1Tx_thread = rt_thread_create("uart1_txTask", uart1_txTask, RT_NULL, 1024, Uart1Tx_thread_pri, 10);
    if(Uart1Tx_thread != RT_NULL){
         rt_thread_startup(Uart1Tx_thread);
    }
    else{
        rt_kprintf("uart1_txTask thread is failed to create!\r\n");
    }
#endif

    while (1)
    {
#if 1
        static uint8_t cpu_usage_major, cpu_usage_minor;
        cpu_usage_get(&cpu_usage_major, &cpu_usage_minor);
        rt_kprintf("CPU USAGE:%u.%u%% \r\n", cpu_usage_major, cpu_usage_minor);
#endif
        rt_thread_mdelay(1000);
        G_ioHandle.toggle(led_1);
    }

    return RT_EOK;
}
